02. Introduction
L3 01 Intro
Introduction
Animation is a powerful tool for helping users understand a potentially complex and confusing screenful of information. When a single item is updated, animating that change can help the user understand what happened. When many items change, animations can help transition the user from one UI to the next, so that they understand the context and implications of the changes.
There are many different kinds of animations that can be used in user interfaces. Items can fade in as they appear, fade out when they disappear, move onto the screen or off of it, geometric shapes can transform in interesting ways. Animations can run by themselves, providing motion to a single object as it changes state, or they can run together with other animations as many changes happen one after the other or in parallel.
Android provides many facilities for animating UI objects. The approach you use, and the APIs or tools you use to create those animations depends on the effect you are trying to achieve. This course will show how to create Property Animations, using ObjectAnimator, which are the basic building blocks of most Android animations. Property animations are used to animate (or change over time) the value of a property on an object, usually a UI object like an Android view.
What you’ll build
In this lesson, you're going to build an application that animates stars on the screen by changing various View properties that control position, size, rotation, and translucency. You will start out with the basic UI of the application, a set of buttons that when pressed will animate the star, as seen here:
Each step of the lesson will create the code to activate one of the buttons in the UI:
- ROTATE will cause the star to spin in a complete circle.
- TRANSLATE will cause the star to move to the right and back.
- SCALE will cause the start to scale up and then back down.
- FADE will cause the star to fade out to completely transparent and then back to fully opaque.
- BACKGROUND COLOR will cause the color of the star’s container to animate between black and red.
- SHOWER will create a new star at the top of the starfield, which will then fall downwards while rotating. Every click will create a new star, animating in parallel with the existing stars.
Along the way, we will introduce ways to make more complex animations, as well as concepts in Kotlin to make the code more elegant and concise.
What you’ll learn
- What properties are and how to animate them.
- How to use
ObjectAnimatorto animate UI elements. - How to configure
ObjectAnimatorfor different UI animation situations. - How to use
AnimatorSetto create a more complex animation of several parts. - How to use
AnimatorListenersto set up initial and final state of objects that are being animated (such as removing views after fading them out).
This course is focused on property animation. The details of the UI are already done for you since they are outside the scope of this lesson.
What you’ll need
Android Studio (version doesn’t matter, but newer tends to be better)